const catchError = async (ctx, next) => {
    try {
        await next();
    } catch (error) {
        if (error.errorCode) {
            ctx.body = {
                msg: error.message,
                error_code: error.errorCode
            };
            ctx.status = error.status
        }
        ctx.body = "服务器炸了";
    }
};

module.exports = catchError;
